package com.zfei.gfb.api.domain;

/**
 * 排序类型
 *
 * @author fgh
 */
public class OrderType {

    /**
     * 升序
     */
    public static final int ASC = 0;

    /**
     * 降序
     */
    public static final int DESC = 1;

    /**
     * 升序
     */
    public static final String STR_ASC = "asc";

    /**
     * 降序
     */
    public static final String STR_DESC = "desc";

    /**
     * 按热度
     */
    public static final int SCORE = 0;

    /**
     * 按时间
     */
    public static final int TIME = 1;


    /**
     * 逆反排序
     *
     * @param orderType order type
     * @return reversed order type
     */
    public static int reverse(int orderType) {
        return orderType == DESC ? ASC : DESC;
    }

    public static int build(Integer orderType) {
        return (orderType == null || orderType == DESC) ? DESC : ASC;
    }

    public static String sqlOrder(Integer orderType) {
        return orderType == 0 ? STR_ASC : STR_DESC;
    }
}
